#encoding: utf-8

import requests
from time import time
from threading import Thread

# class DownloadHanlder(Thread):
# 	"""docstring for DownloadHanlder"""
# 	def __init__(self, url):
# 		super(DownloadHanlder, self).__init__()
# 		self.url = url

# 	def run(self):
# 		filename = self.url[self.url.rfind('/') + 1:] 
# 		resp = requests.get(self.url)
# 		with open('/day14/' + filename, 'wb') as f:
# 			f.write(resp.content)
		
# def main():
# 	resp = requests.get('http://api.tianapi.com/meinv/?key=APIKey&num=10')
# 	data_model = resp.json()
# 	print(data_model)
	# for mm_dict in data_model['msg']:
		# url = mm_dict['picUrl']
		# DownloadHanlder(mm_dict).start()

from socket import socket, SOCK_STREAM, AF_INET
from datetime import datetime


def main():

	server = socket(family = AF_INET, type = SOCK_STREAM)
	server.bind(('192,168.1.101', 9876))
	server.listen(512)
	print('服务器启动监听.......')
	while True:
		client, addr = server.accept()
		print(str(addr) + '连接到了服务器')

		client.send(str(datetime.now()).encode('utf-8'))
		client.close()




if __name__ == '__main__':
	main()


